Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: stack /clear messages #5806

Merged
merged 6 commits into from
Jan 12, 2025
Merged

Conversation

Nerixyz
Copy link
Contributor

@Nerixyz Nerixyz commented Jan 8, 2025

We stack timeouts, but not "full" clearchats. There's no use in having a chat full of "Chat has been cleared by a moderator".

This PR adds similar stacking functionality to /clear messages (both from PubSub and from IRC). Additionally, the user is now clickable in PubSub messages ("{actor} cleared the chat"). Tests for the different stacking settings have been added as well (it reuses the timeout stacking).

@pajlada pajlada enabled auto-merge (squash) January 11, 2025 13:09
@pajlada pajlada disabled auto-merge January 11, 2025 13:37
@pajlada
Copy link
Member

pajlada commented Jan 11, 2025

If I re-run the tests & make it write snapshots, this is the diff I get

diff --git a/tests/snapshots/IrcMessageHandler/clearchat-stack-always.json b/tests/snapshots/IrcMessageHandler/clearchat-stack-always.json
index 0e0b1d11..bc235521 100644
--- a/tests/snapshots/IrcMessageHandler/clearchat-stack-always.json
+++ b/tests/snapshots/IrcMessageHandler/clearchat-stack-always.json
@@ -1,90 +1,6 @@
 {
     "input": "@tmi-sent-ts=1736369068441;rm-received-ts=1736369068532;historical=1;room-id=111448817 :tmi.twitch.tv CLEARCHAT #pajlada",
     "output": [
-        {
-            "badgeInfos": {
-            },
-            "badges": [
-            ],
-            "channelName": "",
-            "count": 4,
-            "displayName": "",
-            "elements": [
-                {
-                    "element": {
-                        "color": "System",
-                        "flags": "Timestamp",
-                        "link": {
-                            "type": "None",
-                            "value": ""
-                        },
-                        "style": "ChatMedium",
-                        "tooltip": "",
-                        "trailingSpace": true,
-                        "type": "TextElement",
-                        "words": [
-                            "20:44"
-                        ]
-                    },
-                    "flags": "Timestamp",
-                    "format": "",
-                    "link": {
-                        "type": "None",
-                        "value": ""
-                    },
-                    "time": "20:44:28",
-                    "tooltip": "",
-                    "trailingSpace": true,
-                    "type": "TimestampElement"
-                },
-                {
-                    "color": "System",
-                    "flags": "Text",
-                    "link": {
-                        "type": "None",
-                        "value": ""
-                    },
-                    "style": "ChatMedium",
-                    "tooltip": "",
-                    "trailingSpace": true,
-                    "type": "TextElement",
-                    "words": [
-                        "Chat",
-                        "has",
-                        "been",
-                        "cleared",
-                        "by",
-                        "a",
-                        "moderator."
-                    ]
-                },
-                {
-                    "color": "System",
-                    "flags": "Text",
-                    "link": {
-                        "type": "None",
-                        "value": ""
-                    },
-                    "style": "ChatMedium",
-                    "tooltip": "",
-                    "trailingSpace": true,
-                    "type": "TextElement",
-                    "words": [
-                        "(4",
-                        "times)"
-                    ]
-                }
-            ],
-            "flags": "System|DoNotTriggerNotification|ClearChat",
-            "id": "",
-            "localizedName": "",
-            "loginName": "",
-            "messageText": "Chat has been cleared by a moderator. (4 times) ",
-            "searchText": "Chat has been cleared by a moderator. (4 times) ",
-            "serverReceivedTime": "",
-            "timeoutUser": "",
-            "usernameColor": "#ff000000"
-        },
         {
             "badgeInfos": {
             },
@@ -219,6 +135,90 @@
             "serverReceivedTime": "2025-01-08T20:44:24Z",
             "timeoutUser": "",
             "usernameColor": "#ffff0000"
+        },
+        {
+            "badgeInfos": {
+            },
+            "badges": [
+            ],
+            "channelName": "",
+            "count": 2,
+            "displayName": "",
+            "elements": [
+                {
+                    "element": {
+                        "color": "System",
+                        "flags": "Timestamp",
+                        "link": {
+                            "type": "None",
+                            "value": ""
+                        },
+                        "style": "ChatMedium",
+                        "tooltip": "",
+                        "trailingSpace": true,
+                        "type": "TextElement",
+                        "words": [
+                            "20:44"
+                        ]
+                    },
+                    "flags": "Timestamp",
+                    "format": "",
+                    "link": {
+                        "type": "None",
+                        "value": ""
+                    },
+                    "time": "20:44:28",
+                    "tooltip": "",
+                    "trailingSpace": true,
+                    "type": "TimestampElement"
+                },
+                {
+                    "color": "System",
+                    "flags": "Text",
+                    "link": {
+                        "type": "None",
+                        "value": ""
+                    },
+                    "style": "ChatMedium",
+                    "tooltip": "",
+                    "trailingSpace": true,
+                    "type": "TextElement",
+                    "words": [
+                        "Chat",
+                        "has",
+                        "been",
+                        "cleared",
+                        "by",
+                        "a",
+                        "moderator."
+                    ]
+                },
+                {
+                    "color": "System",
+                    "flags": "Text",
+                    "link": {
+                        "type": "None",
+                        "value": ""
+                    },
+                    "style": "ChatMedium",
+                    "tooltip": "",
+                    "trailingSpace": true,
+                    "type": "TextElement",
+                    "words": [
+                        "(2",
+                        "times)"
+                    ]
+                }
+            ],
+            "flags": "System|DoNotTriggerNotification|ClearChat",
+            "id": "",
+            "localizedName": "",
+            "loginName": "",
+            "messageText": "Chat has been cleared by a moderator. (2 times) ",
+            "searchText": "Chat has been cleared by a moderator. (2 times) ",
+            "serverReceivedTime": "",
+            "timeoutUser": "",
+            "usernameColor": "#ff000000"
         }
     ],
     "params": {

@pajlada pajlada enabled auto-merge (squash) January 12, 2025 11:14
@pajlada pajlada merged commit 7dbb27e into Chatterino:master Jan 12, 2025
18 checks passed
@Nerixyz Nerixyz deleted the chore/stack-clear branch January 12, 2025 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants